Conversation
dalg24
left a comment
There was a problem hiding this comment.
Honestly I don't really follow the point you are trying to make with this example.
|
@dalg24 Thanks for reviewing! : - )
#117 explains in detail. The point is that users sometimes need to fill a 2-D array where each contiguous segment (e.g., row for |
|
I do not understand how this does what you want with respect to pitched allocations? |
|
I think the accessor needs to store a pitch or some information that every K elements there are 4 extra bytes or whatever. |
|
Also your argument with the alignment doesn't make much sense to me. The object can't say that it is 12byte aligned anyway for pitched allocations, since the whole purpose is that for some rows its not. |
|
Wouldn't this thing do what you want (only posted the relevant parts)? template<class T>
struct pitched_accessor {
int n_every;
int extra_bytes;
using data_handle_type = char*;
pitched_accessor(int n_every_, int extra_bytes_) {
assert(extra_bytes%alignof(T)==0);
}
T& access(const data_handle_type& p, size_t i) {
char* p_offset = p + i*size_of(T) + extra_bytes * (i/n_every);
return *reinterpret_cast<T&>(p_offset);
}
};Probably could have T* as |
This is the example I wrote for the user question here: kokkos#117 Fixes kokkos#248.
0b4dc78 to
83fee78
Compare
* Consolidate public / private declarations * Use bit_cast (restoring constexpr) if the compiler supports it * Remove unused variable
This is the example I wrote for the user question here: #117
Fixes #248.